import { defineStore } from 'pinia'

// @ts-expect-error persist support
export const useUserStore = defineStore('userStore', {
  state: () => {
    return {
      name: '',
      age: 18,
      accessToken: '',
      refreshToken: '',
      count: 0,
    }
  },
  getters: {
    getNick(state) {
      return state.name + ' zs'
    },
  },
  actions: {
    addCount() {
      this.count++
    },
  },
  persist: {
    key: 'xw-pinia-1',
    storage: localStorage,
    paths: ['accessToken', 'refreshToken', 'name', 'count'],
  },
})
